<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/general.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/mui.picker.min.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/mui.poppicker.css"/>
		<style type="text/css">
			.main{
				width: 100%;
				background-color: white;
				padding: 0.5em;
			}
			.place button{
				width:100%;
				color: #676664 !important;
			    border: 0 !important;
			    padding: 11px 15px;
			 	text-align: right;
			}
			.mui-input-row .mui-btn {
			    float: right;
			    width: 60%;
			    padding: 11px 15px;
			}
			.butdiv{
				margin: 2em auto;
				width: 60%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">添加优惠券</h1>
		</header>
		<div class="mui-content">
		    <div class="main">
		    	
		    
		    <div class="mui-input-row border-b fe09" >
    			<label class="wsnowrap">优惠券名称</label>
	    		<input id="coupon_name" type="text" class="textr" placeholder="输入优惠券名字">
		    </div>
		    <div class="mui-input-row border-b fe09" >
    			<label class="wsnowrap">开始时间</label>
	    		<div class="place items" >
				    <button id='data1' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">请选择</button>
				</div>
		    </div>
		    <div class="mui-input-row border-b fe09" >
    			<label class="wsnowrap">到期时间</label>
	    		<div class="place items" >
				    <button id='data2' type="button" class="mui-btn mui-btn-blue mui-btn-outlined">请选择</button>
				</div>
		    </div>
		    <!--
            	作者：592176224@qq.com
            	时间：2019-01-26
            	描述：
		    <div class="mui-input-row border-b">
		        <label>金额：</label>
		        <input id="coupon_money" type="number" class="textr" placeholder="输入数字">
		    </div>
            -->
		    <div class="mui-input-row border-b">
		        <label>满：</label>
		        <input id="man" type="number" class="textr" placeholder="输入数字">
		    </div>
		    <div class="mui-input-row">
		        <label>减：</label>
		        <input id="jian" type="number" class="textr" placeholder="输入数字">
		    </div>
		    </div>
		    
		    <div class="butdiv">
		    	<button id="subbut" type="button" class="mui-btn mui-btn-blue mui-btn-block">添加优惠券</button>
		    </div>
		    
		</div>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.picker.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.poppicker.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/city.data.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			window.onload = function(){
				
				mui.ready(function() {
                
                  var starttime = document.getElementById('data1');
               	  starttime.addEventListener('tap', function(event) {
                	var starttimePicker = new mui.DtPicker({
	                    type: "date",//设置日历初始视图模式    //真正的月份比写的多一个月。  type的类型你还是可以选择date, datetime month time  hour 
	                    beginDate: new Date(2018, 00, 01, 0, 0),//设置开始日期   
	                    endDate: new Date(2050, 12, 31, 0, 0),//设置结束日期    //真正的是10.21
	                    labels: ['年', '月', '日', '时', '分'],//设置默认标签区域提示语 
                	})
                    starttimePicker.show(function(e) {
                    	 starttime.innerText = e.y.text+"-"+e.m.text+"-"+e.d.text;
                    });
                }, false);
                
                var endtime = document.getElementById('data2');
               	  endtime.addEventListener('tap', function(event) {
                	var endtimePicker = new mui.DtPicker({
	                    type: "date",//设置日历初始视图模式    //真正的月份比写的多一个月。  type的类型你还是可以选择date, datetime month time  hour 
	                    beginDate: new Date(2018, 00, 01, 0, 0),//设置开始日期   
	                    endDate: new Date(2050, 12, 31, 0, 0),//设置结束日期    //真正的是10.21
	                    labels: ['年', '月', '日', '时', '分'],//设置默认标签区域提示语 
                	})
                    endtimePicker.show(function(e) {
                    	 endtime.innerText = e.y.text+"-"+e.m.text+"-"+e.d.text;
                    });
                }, false);
                
            	});
            	
            	g("subbut").addEventListener("tap",function(e){
            		var coupon_name = g("coupon_name").value,
            		//coupon_money = g("coupon_money").value,
            		data1 = g("data1").innerHTML,
            		data2 = g("data2").innerHTML,
            		man = g("man").value,
            		jian = g("jian").value;
            		if("" == coupon_name){
            			mui.toast("请输入优惠券名称");return;
            		}
            		if("" == data1){
            			mui.toast("请选择开始时间");return;
            		}
            		if("" == data2){
            			mui.toast("请选择结束时间");return;
            		}
            		if("" == man||"" == jian){
            			mui.toast("请输入使用条件");return;
            		}
            		var data = {
            			url:"/api/Coupon/add",
            			data:{
            				access_token:acctoken(),
            				coupon_name:coupon_name,
            				coupon_money:jian,
            				start_time:data1,
            				end_time:data2,
            				coupon_condition:man
            			}
            		}
            		ajax(data,function(res){
            			console.log("优惠券添加结果",res);
            			mui.toast(res.msg);
            			back_show();
            		})
            		
            	})
			}
			
			function setasdas(){
				
			}
		</script>
	</body>

</html>